package threadLock.lock;

import java.util.concurrent.locks.LockSupport;

/**
 * lockSupport 使用了Unsafe类 实现了线程的挂起与唤醒 对应的就是加锁和解锁的操作
 * synchronized 与当前的这个关键字的用法相似
 * park unpark
 */
public class LockSupportTest {
    public static void main(String[] args) throws InterruptedException {

        Thread thread = new Thread(() -> {
            System.out.println("LockSupport lock park");
            LockSupport.park(Thread.currentThread());
            System.out.println("LockSupport lock unpark");
        });
        thread.start();
        Thread.sleep(10);
        System.out.println("main thread unpark sonThread");
        LockSupport.unpark(thread);
    }
}
